package add__2_basalsyntax;

import java.util.Scanner;

public class While {
    public static void main(String[]args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("欢迎使用中国人民银行ATM取款机");
        int leave = 1000;
        int get = 0;
        //设置死循环,这样就能设置让输入完全决定是否继续循环
        w:while(1 == 1) {
            System.out.println("输入取款金额：");
            get = sc.nextInt();
            int beforeLeave = leave;
            leave = leave - get;
            if(leave < 0) {
                leave = beforeLeave;
                System.out.println("目前余额：" + leave + "无法满足您的取款需求！");
            }else if(leave >= 0) {
                //再次运用死循环
                while(1 == 1) {
                    System.out.println("剩余金额："  + leave + "，是否继续（'1'：结束，'2'：继续）：");
                    int i = sc.nextInt();
                    if(i == 1) {
                        System.out.println("取款结束！");
                        break w;
                    }else if(i == 2) {
                        continue w;
                    }else {
                        continue;
                    }
                }
            }
        }
    }
}
